import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;

/**
 * @Auther: zch
 * @Date: 2019/1/8 17:17
 * @Description:
 */
public class ProducerAndConsumer {
    public static void main(String[] args) throws InterruptedException {

//        BlockingDeque<PCData> queue = new LinkedBlockingDeque<>(10);
//        Producer producer1 = new Producer(queue);
//        Producer producer2 = new Producer(queue);
//        Producer producer3 = new Producer(queue);
//
//        Consumer consumer1 = new Consumer(queue);
//        Consumer consumer2 = new Consumer(queue);
//        Consumer consumer3 = new Consumer(queue);
//
//        ExecutorService service = Executors.newCachedThreadPool();
//        service.execute(producer1);
//        service.execute(producer2);
//        service.execute(producer3);
//        service.execute(consumer1);
//        service.execute(consumer2);
//        service.execute(consumer3);
//        Thread.sleep(1000);
//        producer1.stop();
//        producer2.stop();
//        producer3.stop();
//        Thread.sleep(3000);
////        由于消费者是自循环且无法退出，所以认为任务没完成，无法停止
//        service.shutdown();




    }
}
